<template>
  <div>
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        {{ item }}
        <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="random">生成</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      arr: []
    }
  },

  created () {

  },

  methods: {
    random () {
      this.arr.push(Math.ceil(Math.random() * 20))
    },
    del (index) {
      console.log(this.arr.splice(index, 1))
    }
  }
}
</script>

<style scoped lang='less'>

</style>
